package com.unlcn.ils.crsc.api.scheduled;

import com.unlcn.ils.crsc.service.constant.CronConstant;
import com.unlcn.ils.crsc.service.crsc.CrscOTDService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * 江铃股份订单调度
 * @author liangpeng
 */
@Component
public class OrderOtdScheduled {

    private static final Logger LOGGER = LoggerFactory.getLogger(OrderOtdScheduled.class);

    @Autowired
    private CrscOTDService  crscOTDService;

    /**
     * 拉取在途信息 定时任务
     */
    @Scheduled(cron = CronConstant.OTD_CRON)
    public void getOrderOtd() {
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

        Date now = new Date();

        LOGGER.info(simpleDateFormat.format(now) + "拉取中铁在途订单调度 start ====================");

        crscOTDService.readFTPFilesToSaveDB(now);

        LOGGER.info(simpleDateFormat.format(now) + "拉取中铁在途订单调度 end ====================");
    }
}
